
# 13. 求s=a+aa+aaa+aaaa+aa...a的值，其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加)，几个数相加由键盘控制。
"""
sum = 2+22+222+2222+22222
2  = 2 +0
22 = 20 + 2
222 = 200 + 22
2222 = 2000 + 222
22222 = 20000 + 2222

a = 2
temp = a * 10 ** i  , i 就是循环的次数 ，从0开始循环

sum += temp => sum =  temp  + sum
"""
sum = 0
a = 2
temp = 0
n = int(input("请输入一个数:"))
for i in range(n):
    temp = temp + a * 10 ** i
    sum += temp
print(sum)

# 14. 题目：打印出如下图案（菱形）:
"""
n=1 
n=2
n=3
n=4

x=4
star = "*" * (2n-1)
space = " " * (x-n) 
"""
x = 4
for n in range(1,x+1):
    star = "*" * (2*n-1)
    space = " " * (x - n)
    print(space + star)

for n in range(1,4):
    star = "*" * (7 - 2*n)
    space = " " * n
    print(space + star)


# 第2中写法 ：center()
for n in range(1,x+1):
    star = "*" * (2 * n - 1)
    print(star.center(7,'='))